require "SyntaxObjs"

class Optimizer
  def initialize
    
  end
  
  def Optimizer.Optimize(treeRoot)
    treeRoot || return
    ch = treeRoot.get_childs
    ch && ch.each {|c| 
      Optimize(c)
      eInfo = treeRoot.eval()
      if (eInfo.evalable)
        c = SynConst.new(eInfo.value);
      end
    }
    eInfo = treeRoot.eval()
    if (eInfo.evalable)
      sc = SynConst.new(eInfo.value);
    end
    return treeRoot;
  end
  
end